//
//  BankTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "BankTableViewCell.h"
#import "BankCardModel.h"

@interface BankTableViewCell ()

@property (nonatomic, strong) UIView        *logo;
@property (nonatomic, strong) UIImageView   *bankimg;
@property (nonatomic, strong) UILabel       *bank;
@property (nonatomic, strong) UILabel       *banknumber;
@property (nonatomic, strong) UILabel       *date;
@property (nonatomic, strong) UIButton      *deleteBank;

@end

@implementation BankTableViewCell

+ (BankTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"BankTableViewCell";
    BankTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BankTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

-(void)createSubView{
    UIView *baseview = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), SCREEN_WIDTH - 2 * ScreenX375(13), ScreenX375(134))];
    baseview.layer.cornerRadius = 5.0;
    baseview.backgroundColor = [UIColor blueColor];
    
    
    _logo = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(18), ScreenX375(15), ScreenX375(27), ScreenX375(27))];
    _logo.backgroundColor = [UIColor whiteColor];
    _logo.layer.cornerRadius = 13.5;
    [baseview addSubview: _logo];
    
    _bankimg = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(3.5), ScreenX375(3.5), ScreenX375(20), ScreenX375(20))];
    _bankimg.image = [UIImage imageNamed:@"建行"];
    [_logo addSubview: _bankimg];
    
    _bank =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(55), ScreenX375(22), ScreenX375(200), ScreenX375(14))];
    _bank.font = Kfont(14);
    _bank.textColor = [UIColor whiteColor];
    _bank.textAlignment = NSTextAlignmentLeft;
    [baseview addSubview:_bank];
    
    _banknumber =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(41), ScreenX375(62), ScreenX375(200), ScreenX375(14))];
    _banknumber.font = Kfont(14);
    _banknumber.textColor = [UIColor whiteColor];
    _banknumber.textAlignment = NSTextAlignmentLeft;
    [baseview addSubview:_banknumber];
    
    _date =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(41), ScreenX375(91), ScreenX375(50), ScreenX375(12))];
    _date.font = Kfont(12);
    _date.textColor = [UIColor whiteColor];
    _date.textAlignment = NSTextAlignmentLeft;
    [baseview addSubview:_date];
    
    _deleteBank =[[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(215), ScreenX375(84), ScreenX375(93), ScreenX375(24))];
    [_deleteBank setTitle:@"解除绑定" forState:UIControlStateNormal];
    [_deleteBank setTitleColor:ThemeColor forState:UIControlStateNormal];
    [_deleteBank addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    _deleteBank.titleLabel.font = Kfont(12);
    _deleteBank.titleLabel.textColor = REXADECIMALCOLOR(@"#407cf5");
    _deleteBank.backgroundColor = [UIColor whiteColor];
    _deleteBank.layer.cornerRadius = 12.0;
    [baseview addSubview:_deleteBank];
    
    [self addSubview:baseview];

}

-(void)click{
    NSLog(@"clicked");
}

-(void)initWithModel:(BankCardModel *)model{
    _banknumber.text = model.bank_no;
    _bank.text = model.bank_name;
    _date.text = model.time;
}

@end
